package com.atguigu1.one.exer2;

import java.util.Scanner;

/**
 * ClassName: ArrayExer2
 * Package: com.atguigu1.one.exer2
 * Description:
 * 案例：输出英文星期几
 * <p>
 * 用一个数组，保存星期一到星期天的7个单词，从键盘输入1-7，显示对应的单词
 * {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"}
 *
 * @Author 姜
 * @Create 2023/11/14 9:24
 * @Version 1.0
 */
public class ArrayExer2 {
    public static void main(String[] args) {
        // 定义包含7个单词的数组
        String[] weeks = {"Monday", "Tuesday", "Wednesday","Thursday", "Friday", "Saturday", "Sunday"};

        // 从键盘获取指定的数值，使用Scanner
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入数值(1-7)");
        int day = scanner.nextInt();
        if (day < 1 || day > 7) {
            System.out.println("输入有误");
        } else {
            System.out.println(weeks[day - 1]);
        }
        scanner.close();
    }
}
